'clip example from http://cairographics.org/samples'

out_file_name = __file__[:-1] + 'ng'#'example_clip.png'

surface_width = 256
surface_height = 256

from cairo_ctypes import *

surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, surface_width, surface_height);
cr = cairo_create(surface)

cairo_arc (cr, 128.0, 128.0, 76.8, 0, 2 * M_PI);
cairo_clip (cr);

cairo_new_path (cr);  # current path is not consumed by cairo_clip() */
cairo_rectangle (cr, 0, 0, 256, 256);
cairo_fill (cr);
cairo_set_source_rgb (cr, 0, 1, 0);
cairo_move_to (cr, 0, 0);
cairo_line_to (cr, 256, 256);
cairo_move_to (cr, 256, 0);
cairo_line_to (cr, 0, 256);
cairo_set_line_width (cr, 10.0);
cairo_stroke (cr);

cairo_surface_write_to_png(surface, out_file_name)

print('Result see in %s' % out_file_name)
